#include <iostream>
#include <iomanip>
using namespace std;

void managerialSystem(int);

class Student { //学生类对象
    private:
        string name;    //姓名
        bool sex;   //性别，true表示男，false表示女
        int classes;    //班级号
        double height;

    //构造方法和析构函数
    public:
        Student() {
            
        }

        Student(string name, bool sex, int classes, double height) {
            this->name = name;
            this->sex = sex;
            this->classes = classes;
            this->height = height;
        }

        ~Student() {
            
        }
    //各属性的getter和setter
    public:
        string getName() {
            return this->name;
        }

        void setName(string name) {
            this->name = name;
        }

        bool getSex() {
            return this->sex;
        }

        void setSex(bool sex) {
            this->sex = sex;
        }

        int getClasses() {
            return this->classes;
        }

        void setClasses(int classes) {
            this->classes = classes;
        }

        double getHeight() {
            return this->height;
        }

        void setHeight(double height) {
            this->height = height;
        }
};

int main() {
    managerialSystem(4);
    return 0;
}


//输入函数
void managerialSystem(int n) {
    int boy = 0;    //统计男孩子的数量  
    int girl = 0;   //统计女孩子的数量  
    double sumOfBoysHeight = 0; //记录男孩子身高之和    
    double sumOfgirlsHeight = 0;    //记录女孩子身高之和
    Student students[n];    //用来存储学生信息的Student对象数组
    for (int i = 0; i < n; i++) {   //通过for循环来输入n个学生的信息
        cout << "请输入第" << i+1 << "个学生的姓名：";
        string name;
        cin >> name;
        students[i].setName(name);
        cout << endl;
        cout << "请输入第" << i+1 << "个学生的性别（1：男，0：女）：";
        bool sex;
        cin >> sex;
        if (sex) {
            boy++;
        } else {
            girl++;
        }
        students[i].setSex(sex);
        cout << endl;
        cout << "请输入第" << i+1 << "个学生的班级：";
        int classes;
        cin >> classes;
        students[i].setClasses(classes);
        cout << endl;
        cout << "请输入第" << i+1 << "个学生的身高：";
        double height;
        cin >> height;
        if (sex) {
            sumOfBoysHeight += height;
        } else {
            sumOfgirlsHeight += height;
        }
        students[i].setHeight(height);
        cout << endl;
    }

    for (int i = 0; i < n; i++) {   //通过for循环来输出n个学生的信息
        cout << "姓名：" << students[i].getName() << endl;
        if(students[i].getSex()) {
            cout << "性别：男" << endl;
        } else {
            cout << "性别：女" << endl;
        }       
        cout << "班级：" << students[i].getClasses() << endl;
        cout << "身高：" << students[i].getHeight() << endl;
        cout << endl;
    }

    //输出男孩子和女孩子的平均身高
    if (boy) {
        cout << "男孩子平均身高为：" << fixed << setprecision(2) << sumOfBoysHeight/boy << endl;
    } else {
        cout << "没有统计到男孩子的身高" << endl;
    }

    if (girl) {
        cout << "女孩子平均身高为：" << fixed << setprecision(2) << sumOfgirlsHeight/girl << endl;
    } else {
        cout << "没有统计到女孩子的身高";
    }
}